import random
import string

with open('big.txt','w+',encoding = "utf-8") as f:
    line_num = random.randint(1, 100)   #生成随机行数
    for j in range(line_num):
        f.write(("".join(random.choices(string.ascii_lowercase,k = random.randint(1,50)))+"\n"))  #生成随机长度的内容


def read_file():
    with open('big.txt','r+') as f:
        # 返回每一行的长度（不包括换行符）
        length = [len(line.strip('\n')) for line in f]     #注：不能用readlines,readlines会把它全部读取到内存
        yield from length
a = read_file()
b = [i for i in a ]
print(max(b))
